target = script.vars[0]
check_target = $h_pass.nil? ? target : $h_pass
$h_pass = nil

c, found = 1, nil
until ['hunt','area','here'].include?(found = hunt_target(target, c))
  (wait_until {Char.enemy.empty?};next) if found == "fighting"
  c += 1
end
exit if found == 'area'

if found == 'here'
  echo "Found '#{target}'!"
  put("k #{target}")
  exit
end
rooms = where_cp(target, c, check_target)

while (room = rooms.shift)
  go2(room)
  exit unless Room.current.db_id == room
  mobs = get_con[0]
  mobs.each {|m| (echo "Found '#{full_mob}'!";put("k #{target}");exit) if m =~ /#{Regexp.quote(full_mob)}/i}
end